package com.ruoyi.web;

import com.aspose.cad.InterpolationMode;
import com.aspose.cad.SmoothingMode;
import com.aspose.cad.TextRenderingHint;
import com.aspose.cad.fileformats.cad.CadDrawTypeMode;
import com.aspose.cad.imageoptions.CadRasterizationOptions;
import com.aspose.cad.imageoptions.PngOptions;
import com.aspose.cad.imageoptions.SvgOptions;

public class Test {

    public static void main(String[] args) {
        //加载PDF
//        String absParsingFile = "D:/dfx/暖气位置建议图.dwg";
        String absParsingFile = "C:\\Users\\86183\\Desktop\\测试文件\\2018.dwg";
        com.aspose.cad.Image cadImage = com.aspose.cad.Image.load(absParsingFile);
        CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
        rasterizationOptions.setPageWidth(3500);
        rasterizationOptions.setPageHeight(1500);
        rasterizationOptions.setAutomaticLayoutsScaling(true);
        rasterizationOptions.setNoScaling(false);
        rasterizationOptions.setContentAsBitmap(true);
        rasterizationOptions.setLayouts(new String[]{"Model"});
        rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);

//        PngOptions pngOptions = new PngOptions();
//        pngOptions.setVectorRasterizationOptions(rasterizationOptions);

        SvgOptions svgOptions = new SvgOptions();
        svgOptions.setVectorRasterizationOptions(rasterizationOptions);

        // Set Graphics options
        rasterizationOptions.getGraphicsOptions().setSmoothingMode(SmoothingMode.HighQuality);
        rasterizationOptions.getGraphicsOptions().setTextRenderingHint(TextRenderingHint.AntiAliasGridFit);
        rasterizationOptions.getGraphicsOptions().setInterpolationMode(InterpolationMode.HighQualityBicubic);

        // Export to PDF by calling the Save method
        cadImage.save("C:\\Users\\86183\\Desktop\\2018.svg", svgOptions);
    }
}
